from lianxi.xiecheng.base import base
from selenium.webdriver.common.by import By
from selenium import webdriver

class boat_page(base):
    boat1 = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[15]/a')#悬停
    boat2 = (By.LINK_TEXT, '船票')#点击船票
    boat3 = (By.XPATH, '/html/body/div[2]/div/div[1]/div[1]/div[2]/div[2]')#点击查询
    boat4 = (By.XPATH, '/html/body/div[2]/div/div[2]/div[1]/div[3]/div[2]/div/div[4]/div')#选择舱位
    boat5 = (By.XPATH, '/html/body/div[2]/div/div[2]/div[1]/div[3]/div[2]/div[2]/div[2]/div[5]/div')#点击预订
    boat6 = (By.XPATH, '/html/body/div[2]/div/div[3]/div[1]/div[2]/div[2]/div[1]/div/div[1]/div')#选择乘客'
    boat7 = (By.XPATH, '/html/body/div[2]/div/div[3]/div[1]/div[3]/div[2]/div[1]/input')#输入手机号
    boat8 = (By.XPATH, '/html/body/div[2]/div/div[3]/div[1]/div[5]/div[3]')#点击去支付

    url = 'https://www.ctrip.com/'# 网址
    ty = '730130'

    def boat(self):

        self.get_url(self.url)
        self.get_sleep()
        self.add_cookie()
        self.get_sx()
        self.get_sleep()
        self.get_move(*self.boat1)
        self.get_sleep()
        self.get_click(*self.boat2)
        self.get_sleep()
        self.get_click(*self.boat3)
        self.get_sleep()
        self.get_max()
        self.get_click(*self.boat4)
        self.get_sleep()
        self.driver.execute_script("window.scrollTo(0,200)")
        self.get_sleep()
        self.get_click(*self.boat5)
        self.get_sleep()
        self.get_click(*self.boat6)
        self.get_sleep()
        self.driver.execute_script("window.scrollTo(0,800)")
        self.get_sleep()
        self.get_text(self.ty,*self.boat7)
        self.get_sleep()
        self.get_click(*self.boat8)
        self.get_sleep()
